package generator.util

object captureName {
  def captureName(name: String, isUp: Boolean): String = {
    if (name == null || name == "") return ""
    //char[] cs = name.toCharArray();
    //首字母是小写的需要大写
    //if(cs[0] >= 97 && cs[0] <= 122) {
    //	cs[0] -= 32;
    //}
    //return String.valueOf(cs);
    //public static String changeToJavaFiled(String field) {
    val fields = name.toLowerCase.split("_")
    val sbuilder = new StringBuilder(fields(0))
    // System.out.println("列字段：  "+name);
    //        if(name.equals("FREEZE__FALG")){
    //            System.out.println("lllllll");
    //        }
    for (i <- 1 until fields.length) {
      val cs = fields(i).toCharArray
      if (cs.length != 0) {
        cs(0) = cs(0).toUpper
        sbuilder.append(String.valueOf(cs))
      }
    }
    var captureName = sbuilder.toString
    if (isUp) {
      val cs = captureName.toCharArray
      //首字母是小写的需要大写
      if (cs(0) >= 97 && cs(0) <= 122) cs(0) = cs(0).toUpper
      captureName = String.valueOf(cs)
    }
    captureName
    //}
  }
}
